//
// Created by Jisam on 23/10/2024 22:08.
// Solution of  template
#include <bits/stdc++.h>

#define  int long long
#define  endl "\n"
#define  all(x) (x).begin(),(x).end()
#define  pb push_back
using namespace std;


void get_primes(int n, vector<int>& primes,vector<int>& is_prime) {
    is_prime[0] = is_prime[1] = false; // 0 和 1 不是素数

    for (int i = 2; i <= n; ++i) {
        if (is_prime[i]) {
            primes.push_back(i);
        }
        for (int j = 0; j < primes.size() && i * primes[j] <= n; ++j) {
            is_prime[i * primes[j]] = false;
            if (i % primes[j] == 0) {
                break;
            }
        }
    }
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    int n = 105; 
    vector<int> primes;
    vector<int> is_prime(n + 1, 1);
    get_primes(n, primes,is_prime);

    for (int prime : primes) {
        if(prime >= a  && prime <= b && is_prime[prime % 10 * 10 + prime / 10])
        cout << prime << endl;
    }
    return 0;
}